import { createSlice } from "@reduxjs/toolkit";

const counterStore = createSlice({
    name: 'counter',
    initialState: {
        count: 761
    },
    // 修改数据方法，支持直接修改
    reducers: {
        inscrement(state) {
            state.count++
        },
        decscrement(state) {
            state.count--
        },
        addToNum(state, action) {
            state.count = action.payload
        }
    },
})

const { inscrement, decscrement, addToNum } = counterStore.actions

const reducer = counterStore.reducer

// 按需导入
export { inscrement, decscrement, addToNum }
// 默认导出
export default reducer